package com.ruoyi.task.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.task.domain.TaskPlaceCount;
import com.ruoyi.task.service.ITaskPlaceCountService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 景区人数管理Controller
 * 
 * @author ruoyi
 * @date 2023-04-09
 */
@RestController
@RequestMapping("/task/place_count")
public class TaskPlaceCountController extends BaseController
{
    @Autowired
    private ITaskPlaceCountService taskPlaceCountService;

    /**
     * 查询景区人数管理列表
     */
    @PreAuthorize("@ss.hasPermi('task:place_count:list')")
    @GetMapping("/list")
    public TableDataInfo list(TaskPlaceCount taskPlaceCount)
    {
        startPage();
        List<TaskPlaceCount> list = taskPlaceCountService.selectTaskPlaceCountList(taskPlaceCount);
        return getDataTable(list);
    }

    /**
     * 导出景区人数管理列表
     */
    @PreAuthorize("@ss.hasPermi('task:place_count:export')")
    @Log(title = "景区人数管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TaskPlaceCount taskPlaceCount)
    {
        List<TaskPlaceCount> list = taskPlaceCountService.selectTaskPlaceCountList(taskPlaceCount);
        ExcelUtil<TaskPlaceCount> util = new ExcelUtil<TaskPlaceCount>(TaskPlaceCount.class);
        util.exportExcel(response, list, "景区人数管理数据");
    }

    /**
     * 获取景区人数管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('task:place_count:query')")
    @GetMapping(value = "/{placeId}")
    public AjaxResult getInfo(@PathVariable("placeId") Long placeId)
    {
        return success(taskPlaceCountService.selectTaskPlaceCountByPlaceId(placeId));
    }

    /**
     * 新增景区人数管理
     */
    @PreAuthorize("@ss.hasPermi('task:place_count:add')")
    @Log(title = "景区人数管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TaskPlaceCount taskPlaceCount)
    {
        return toAjax(taskPlaceCountService.insertTaskPlaceCount(taskPlaceCount));
    }

    /**
     * 修改景区人数管理
     */
    @PreAuthorize("@ss.hasPermi('task:place_count:edit')")
    @Log(title = "景区人数管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TaskPlaceCount taskPlaceCount)
    {
        return toAjax(taskPlaceCountService.updateTaskPlaceCount(taskPlaceCount));
    }

    /**
     * 删除景区人数管理
     */
    @PreAuthorize("@ss.hasPermi('task:place_count:remove')")
    @Log(title = "景区人数管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{placeIds}")
    public AjaxResult remove(@PathVariable Long[] placeIds)
    {
        return toAjax(taskPlaceCountService.deleteTaskPlaceCountByPlaceIds(placeIds));
    }
}
